<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:icecore="http://www.icefaces.org/icefaces/core"
      xmlns:ace="http://www.icefaces.org/icefaces/components"
      xmlns:ice="http://www.icesoft.com/icefaces/component">

   <h:head>
     <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
     <title>Tribble Score Padd Application</title>
     <link rel="stylesheet" type="text/css" href="../StyleWeb/trek_css/style.css" />
     <link rel="stylesheet" type="text/css" href="../StyleWeb/xmlhttp/css/rime/rime.css" />
     <link href="./images/tribble2.ico" rel="shortcut icon" type="image/x-icon"></link>
     <link href="./images/tribble2.ico" rel="icon" type="image/x-icon"></link>
  </h:head>

  <h:body>
     <!-- In order to use this you have to have a reference in the faces-config.xml file... -->
     <ice:loadBundle var="msgs" basename="resources.messages" />

     <ice:form id="form" partialSubmit="true">

        <!--  BEGIN: Enter the player's names -->
        <ice:panelGroup >
           <ice:panelPopup id="enterNamesPopup" draggable="true"
                           modal="true" visible="#{formBean.addNamesPopupRendered}"
                           autoCenter="false" styleClass="corePopup">
              <f:facet name="header">
                 <ice:panelGroup styleClass="popupHeaderWrapper">
                    <ice:outputText value="Enter Participating Tribble Players..." styleClass="popupHeaderText"/>
                    <ice:commandButton type="button" image="images/popupclose.gif"
                                       actionListener="#{formBean.toggleAddNamesPopup}"
                                       styleClass="popupHeaderImage" title="Close Popup" alt="Close" />
                 </ice:panelGroup>
              </f:facet>

              <f:facet name="body">
                 <ice:panelGroup styleClass="popupBody"> <center>
                    <ice:panelGrid id="dataEntry" columns="2">
                       <ice:outputText value="Please Enter Player's Name:" />
                       <ice:inputText id="playerName" partialSubmit="true" tabindex="1"
                                      validator="#{formBean.validatePlayerNameBeforeAdd}"
                                      binding="#{formBean.nameText}"
                                      title="Enter name...." required="true" value="#{formBean.name}">
                          <f:validateLength for="playerName" minimum="2" />
                       </ice:inputText>

                       <ice:commandButton id="addPlayerBtn" value="Add Tribble Player" tabindex="2"
                                          actionListener="#{formBean.addPlayer}" title="Add Tribble Player"
                                          style="float: right; margin-top: 2px; margin-right: 2px;" />

                       <ice:commandButton value="Done" immediate="true" type="submit" tabindex="0"
                                          actionListener="#{formBean.toggleAddNamesPopup}"
                                          title="Press to start scoring..."
                                          style="float: right; margin-top: 2px; margin-right: 2px;" />

                    </ice:panelGrid> </center>
                    <ice:message for="playerName" style="color:red; width:150px; overflow:auto;"/>
                 </ice:panelGroup>
              </f:facet>
           </ice:panelPopup>
        </ice:panelGroup>
        <!--  END  : Enter the player's names -->

<!-- ////////////////////////////////////////////////////////////////////////////////// -->

        <!-- START : Main page -->
        <ice:panelGroup> <ice:panelGrid columns="1" style="padding: 5px;">

           <!-- START : Show/Enter Current Round -->
           <ice:panelGrid columns="4" style="vertical-align:bottom;">
              <ice:outputLabel value="Current Round: "/>
              <ice:inputText id="currRoundId" required="true" value="#{formBean.currentRound}" style="width: 15px; text-align:center;">
                 <f:validateLongRange minimum="1" maximum="5" />
              </ice:inputText>
              <ice:commandButton value="Advance" actionListener="#{formBean.advanceRound}"
                                 partialSubmit="true" styleClass="tribbleScoreBtn"
                                 title="Click to advance to the next round." />
              <ice:message for="currRoundId" style="color:red;"/>
           </ice:panelGrid>
           <!-- END   : Show/Enter Current Round -->

           <!-- START : Player Score Padd -->
           <ice:dataTable id="playerTable" value="#{formBean.players}" var="player" rows="6">
              <!--  COLUMN : SELECTED --> 
              <ice:column style="text-align:center;">
                 <f:facet name="header"> <ice:outputText value="Scored"/> </f:facet>
                 <ice:selectBooleanCheckbox value="#{player.selected}"/>
              </ice:column>

              <!--  COLUMN : Name --> 
              <ice:column>
                 <f:facet name="header"> <ice:outputText value="Name"/> </f:facet>
                 <ice:outputText value="#{player.name}" style="font-family: Courier;"/>
              </ice:column>

              <!--  COLUMN : Round 1 Score--> 
              <ice:column style="text-align:right;">
                 <f:facet name="header"> <ice:outputText value="Round 1"/> </f:facet>
                 <ice:panelGroup panelTooltip="r1ToolTip">
                    <ice:outputText value="#{player.roundOne.totalScore}"/>
                 </ice:panelGroup>
                 <ice:panelTooltip id="r1ToolTip">
                    <f:facet name="body"> <ice:outputText value="#{player.roundOne.toStringForToolTip}" style="white-space:pre-wrap; font-family: Courier;" escape="false"/> </f:facet>
                 </ice:panelTooltip>
              </ice:column>

              <!--  COLUMN : Round 2 Score--> 
              <ice:column style="text-align:right;">
                 <f:facet name="header"> <ice:outputText value="Round 2"/> </f:facet>
                 <ice:panelGroup panelTooltip="r2ToolTip">
                    <ice:outputText value="#{player.roundTwo.totalScore}" />
                 </ice:panelGroup>
                 <ice:panelTooltip id="r2ToolTip">
                    <f:facet name="body"> <ice:outputText value="#{player.roundTwo.toStringForToolTip}" style="white-space:pre-wrap; font-family: Courier;" escape="false"/> </f:facet>
                 </ice:panelTooltip>
              </ice:column>

              <!--  COLUMN : Round 3 Score--> 
              <ice:column style="text-align:right;">
                 <f:facet name="header"> <ice:outputText value="Round 3"/> </f:facet>
                 <ice:panelGroup panelTooltip="r3ToolTip">
                    <ice:outputText value="#{player.roundThree.totalScore}" />
                 </ice:panelGroup>
                 <ice:panelTooltip id="r3ToolTip">
                    <f:facet name="body"> <ice:outputText value="#{player.roundThree.toStringForToolTip}" style="white-space:pre-wrap; font-family: Courier;" escape="false"/> </f:facet>
                 </ice:panelTooltip>
              </ice:column>

              <!--  COLUMN : Round 4 Score--> 
              <ice:column style="text-align:right;">
                 <f:facet name="header"> <ice:outputText value="Round 4"/> </f:facet>
                 <ice:panelGroup panelTooltip="r4ToolTip">
                    <ice:outputText value="#{player.roundFour.totalScore}" />
                 </ice:panelGroup>
                 <ice:panelTooltip id="r4ToolTip">
                    <f:facet name="body"> <ice:outputText value="#{player.roundFour.toStringForToolTip}" style="white-space:pre-wrap; font-family: Courier;" escape="false"/> </f:facet>
                 </ice:panelTooltip>
              </ice:column>

              <!--  COLUMN : Round 5 Score--> 
              <ice:column style="text-align:right;">
                 <f:facet name="header"> <ice:outputText value="Round 5"/> </f:facet>
                 <ice:panelGroup panelTooltip="r5ToolTip">
                    <ice:outputText value="#{player.roundFive.totalScore}" />
                 </ice:panelGroup>
                 <ice:panelTooltip id="r5ToolTip">
                    <f:facet name="body"> <ice:outputText value="#{player.roundFive.toStringForToolTip}" style="white-space:pre-wrap; font-family: Courier;" escape="false"/> </f:facet>
                 </ice:panelTooltip>
              </ice:column>
     
              <!--  COLUMN : Total Score--> 
              <ice:column style="text-align:right;">
                 <f:facet name="header"> <ice:outputText value="Total"/> </f:facet>
                 <ice:outputText value="#{player.totalScore}" />
              </ice:column>
           </ice:dataTable>
           <!-- END   : Player Score Padd -->

           <!-- START : Score Type Buttons -->
           <ice:panelGroup>
              <ice:panelGrid columns="1" rowClasses="row1, row2, row3" style="display: block; margin: auto; text-align: center;">
                 <ice:panelGrid columns="4">
                    <ice:commandButton value="POISON" actionListener="#{formBean.scorePoison}"
                                       partialSubmit="true" styleClass="tribbleScoreBtn"
                                       title="Score points" />
                    <ice:commandButton value="TOXIN" actionListener="#{formBean.scoreToxin}"
                                       partialSubmit="true" styleClass="tribbleScoreBtn"
                                       title="Score points" />
                    <ice:commandButton value="ANTIDOTE" actionListener="#{formBean.scoreAntidote}"
                                       partialSubmit="true" styleClass="tribbleScoreBtn"
                                       title="Score points" />
                    <ice:commandButton value="SCORE" actionListener="#{formBean.scoreScore}"
                                       partialSubmit="true" styleClass="tribbleScoreBtn"
                                       title="Score points" />
                 </ice:panelGrid>
                 <ice:panelGrid columns="4">
                    <ice:commandButton value="TALLY" actionListener="#{formBean.scoreTally}"
                                       partialSubmit="true" styleClass="tribbleScoreBtn"
                                       title="Score points" />
                    <ice:commandButton value="COPY" actionListener="#{formBean.scoreCopy}"
                                       partialSubmit="true" styleClass="tribbleScoreBtn"
                                       title="Score points" />
                    <ice:commandButton value="BONUS" actionListener="#{formBean.scoreBonus}"
                                       partialSubmit="true" styleClass="tribbleScoreBtn"
                                       title="Score points" />
                    <ice:commandButton value="QUADRUPLE" actionListener="#{formBean.scoreQuadruple}"
                                       partialSubmit="true" styleClass="tribbleScoreBtn"
                                       title="Score points" />
                 </ice:panelGrid>
                 <ice:panelGrid columns="1">
                    <ice:commandButton value="WINNER" actionListener="#{formBean.scoreWinner}"
                                       partialSubmit="true" styleClass="tribbleScoreBtn"
                                       title="Score points" />
                 </ice:panelGrid>
              </ice:panelGrid>
           </ice:panelGroup>
           <!-- END   : Score Type Buttons -->

        </ice:panelGrid> </ice:panelGroup>
        <!--  END  : Main page -->

<!-- ////////////////////////////////////////////////////////////////////////////////// -->

        <!-- START : Scorecard Popup -->
        <!-- code to set the default input focus
        <script> document.getElementById('form:enterScorePopup:hundredThousandsAmount').focus(); </script>
         -->
        <ice:panelGroup styleClass="panelPopupContainer" visible="#{formBean.scorePaddPopupRendered}">
           <ice:panelPopup id="enterScorePopup" draggable="true"
                           modal="true" visible="#{formBean.scorePaddPopupRendered}"
                           autoCenter="true" styleClass="scorePaddPopup">

              <!-- START : Enter Score -->
              <f:facet name="header">
                 <ice:panelGroup styleClass="popupHeaderWrapper">
                    <ice:outputText value="Enter the number of tribble's cards scored below..." styleClass="popupHeaderText"/>
                    <ice:commandButton type="button" image="images/popupclose.gif"
                                       actionListener="#{formBean.closeScorePaddPopup}"
                                       styleClass="popupHeaderImage" title="Close Popup" alt="Close" />
                 </ice:panelGroup>
              </f:facet>

              <f:facet name="body"> <ice:panelGrid columns="1" cellspacing="2px">
                 <ice:panelGrid columns="6" cellspacing="2px">
                    <ice:inputText id="hundredThousandsAmount" partialSubmit="true"
                                   styleClass="tribbleScoreTxt"
                                   title="Enter number of hundred thousand tribbles scored...."
                                   tabindex="1"
                                   value="#{formBean.hundredThousands}">
                       <f:validateLongRange minimum="0" />
                    </ice:inputText>

                    <ice:inputText id="tenThousandsAmount" partialSubmit="true"
                                   styleClass="tribbleScoreTxt"
                                   title="Enter number of ten thousand tribbles scored...."
                                   tabindex="2"
                                   value="#{formBean.tenThousands}">
                       <f:validateLongRange minimum="0" />
                    </ice:inputText>

                    <ice:inputText id="thousandsAmount" partialSubmit="true"
                                   styleClass="tribbleScoreTxt"
                                   title="Enter number of thousand tribbles scored...."
                                   tabindex="3"
                                   value="#{formBean.thousands}">
                       <f:validateLongRange minimum="0" />
                    </ice:inputText>

                    <ice:inputText id="hundredsAmount" partialSubmit="true"
                                   styleClass="tribbleScoreTxt"
                                   title="Enter number of hundred tribbles scored...."
                                   tabindex="4"
                                   value="#{formBean.hundreds}">
                       <f:validateLongRange minimum="0" />
                    </ice:inputText>

                    <ice:inputText id="tensAmount" partialSubmit="true"
                                   styleClass="tribbleScoreTxt"
                                   title="Enter number of ten tribbles scored...."
                                   tabindex="5"
                                   value="#{formBean.tens}">
                       <f:validateLongRange minimum="0" />
                    </ice:inputText>

                    <ice:inputText id="onesAmount" partialSubmit="true"
                                   styleClass="tribbleScoreTxt"
                                   title="Enter number of one tribbles scored...."
                                   tabindex="6"
                                   value="#{formBean.ones}">
                       <f:validateLongRange minimum="0" />
                    </ice:inputText>

                    <ice:outputLabel value="100k's" styleClass="tribbleScoreLbl"/>
                    <ice:outputLabel value="10k's"  styleClass="tribbleScoreLbl"/>
                    <ice:outputLabel value="1k's"   styleClass="tribbleScoreLbl"/>
                    <ice:outputLabel value="100's"  styleClass="tribbleScoreLbl"/>
                    <ice:outputLabel value="10's"   styleClass="tribbleScoreLbl"/>
                    <ice:outputLabel value="1's"    styleClass="tribbleScoreLbl"/>
                 </ice:panelGrid>
                 <!-- END   : Enter Score -->
                 <p/> <p/>

                 <!-- START : Buttons ...-->
                 <ice:panelGrid columns = "3">
                    <ice:commandButton value="Cancel" actionListener="#{formBean.closeScorePaddPopup}"
                                       partialSubmit="true" styleClass="tribbleScoreBtn"
                                       title="Cancel this action..." />
                    <ice:commandButton value="Clear" actionListener="#{formBean.clearScore}"
                                       partialSubmit="true" styleClass="tribbleScoreBtn" immediate="true"
                                       title="Clear entered amounts..." />
                    <ice:commandButton value="Score" actionListener="#{formBean.scorePoints}"
                                       partialSubmit="true" styleClass="tribbleScoreBtn"
                                       title="Score for selected players..." />
                 </ice:panelGrid>
                 <!-- END   : Buttons ...-->
              </ice:panelGrid> </f:facet>
           </ice:panelPopup>
        </ice:panelGroup>
        <!-- END   : Scorecard Popup -->

<!-- ////////////////////////////////////////////////////////////////////////////////// -->

        <!-- START : Tournament Directory Activities -->
        <hr/>
        
        <ice:panelGrid columns="2" cellpadding="5px">
           <f:facet name="header">
              <ice:outputText value="Tournament Director Activities..." style="float:left;"/>
           </f:facet>
           <ice:commandButton id="addMorePlyrsBtn" type="submit"
                              value="Add More Player(s)" partialSubmit="true"
                              title="Add a new player mid-game..." />

           <ice:commandButton id="manualScoreUpdate" type="submit"
                              value="Manual Score Update" partialSubmit="true"
                              title="Manually update a player's score incase of mistakes etc..." />
        </ice:panelGrid>
        <!-- END   : Tournament Directory Activities -->

<!-- ////////////////////////////////////////////////////////////////////////////////// -->

        <!-- START : Error Message Popup -->
        <ice:panelPopup id="formBeanModalPnlPop" draggable="false" modal="true"
                        visible="#{formBean.errorMessagePopupRendered}" autoCentre="true">
           <f:facet name="header"> <ice:panelGroup styleClass="popupHeaderWrapper">
              <ice:outputText value="Error messages..." styleClass="popupHeaderText" style="float:left;"/>
              <ice:commandButton type="button" image="images/popupclose.gif"
                                 actionListener="#{formBean.toggleErrorMessagePopup}"
                                 style="float: right; margin-top: 2px; margin-right: 2px;"
                                 immediate="true" title="Close Popup" alt="Close"/>
           </ice:panelGroup> </f:facet>

           <f:facet name="body"> <ice:panelGroup>
              <ice:outputText value="#{formBean.errorMessagePopup}" style="float:left; color:red;"/> <br/><p/>
              <ice:commandButton id="formBeanModalPnlCloseButton" type="submit"
                                 value="Close" immediate="true" style="float:right;"
                                 actionListener="#{formBean.toggleErrorMessagePopup}"/>
           </ice:panelGroup> </f:facet>
        </ice:panelPopup>
        <!-- END   : Error Message Popup -->

<!-- ////////////////////////////////////////////////////////////////////////////////// -->
     </ice:form>
  </h:body>
  

  <h:outputStylesheet library="org.icefaces.component.skins" name="rime.css" />
</html>